# Maintainer: Runnytu < runnytu at gmail.com >
# Contributor: Christian Hammacher < bmasterc@gmail.com >

pkgname=dkms-8192cu
pkgver=v4.0.2_9000.20130911
pkgrel=2
pkgdesc="Driver for Realtek RTL8188CUS (8188C, 8192C) chipset wireless cards"
arch=('arm')
url="http://www.realtek.com.tw/"
license=('GPL')
depends=('dkms' 'linux-headers')
conflicts=("8192cu" "rt8192cu")
install=${pkgname}.install
options=(!strip)
_pkgname="8192cu"
source=("https://www.dropbox.com/s/61askvmgh6iyh6p/rtl8188C_8192C_usb_linux_$pkgver.tar.gz"
        "dkms-8192cu.install"
        "fix_310_proc.patch"
        "add_missing_ids_netgear_dlink.patch"
        "dkms.conf"
        "blacklist-dkms-8192cu.conf")
               
md5sums=('efb71a576f781c3d15531511aac2c5c9'
         '82db3ab6573dbe2ede43e49ac35259cb'
         '5b764e13afd1ccad5bb14bd4d9633604'
         'cf582713c3a65eaff137feb22d93b61c'
         '21077239f17639254b74d74daea8655b'
         '5f2d28bf3839447bfe762416a89e1a21')

package() {
       
        installDir="$pkgdir/usr/src/$_pkgname-$pkgver"
       
        install -dm755 "$installDir"
        install -m644 "$srcdir/dkms.conf" "$installDir/dkms.conf"
        install -dm755 "$pkgdir/etc/modprobe.d"
        install -m644 "$srcdir/blacklist-dkms-8192cu.conf" "$pkgdir/etc/modprobe.d/blacklist-dkms-8192cu.conf"
       
        cd "${srcdir}/rtl8188C_8192C_usb_linux_${pkgver}/"

        patch -p1 -i "$srcdir/fix_310_proc.patch"
        patch -p1 -i "$srcdir/add_missing_ids_netgear_dlink.patch"

	# Disable power saving
	sed -i 's/^CONFIG_POWER_SAVING \= y/CONFIG_POWER_SAVING = n/' Makefile

	# Fix __TIME__ macros error
	sed -i 's/^#define CONFIG_DEBUG_RTL819X/\ /' include/autoconf.h 

        for d in `find . -type d`
        do
                install -dm755  "$installDir/$d"
        done
       
        for f in `find . -type f`
        do
                install -m644 "${srcdir}/rtl8188C_8192C_usb_linux_${pkgver}/$f" "$installDir/$f"
        done
       
}
